package com.lqk.iterator;

import java.util.Iterator;

/**
 * @author lqk
 * @date 2021/12/9 19:33
 */
public class ComputerCollegeIterator implements Iterator {

    // 这里我们需要知道 Department 是以怎样的方式存放的 =》 数组
    Department[] departments;
    int position = 0;   // 表示遍历的位置

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (position >= departments.length || departments[position] == null){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Object next() {
        Department department = departments[position];
        position += 1;
        return department;
    }

    // 删除的方法默认空实现
    @Override
    public void remove() {

    }
}
